<style type="text/css">
iframe{
	visibility:hidden;
	display:none;	
}
.progress-bar {
     border: 1px solid #56577A; 
     width: 200px; 
     margin: 5px; 
     padding: 1px; 
     background: #fff;
	 float: left;
	 text-align:center;
   }

   .bar {
     height: 15px;
	 font-size: 11px;
	 text-indent:-9000px;
	 text-align:center;
   }
   
   #percentage{
    float: left;
	margin-left: 10px;
	margin-top:4px;
   }

</style>


<script src="progressbar2.js" type="text/javascript"></script>
<table align="center">
<tr><td>
<div class="progress-bar">          
    <div id ="sample" class="bar">100%</div>
  </div>
  <div id ="percentage"></div>
</td>  </tr>
</table>
<script>
<?php
if(isset($_GET['msg']) && isset($_GET['fecha1']) && isset($_GET['hora1'])){
	$link = mysql_connect("localhost", "admin", "Xurpas123");
	mysql_select_db("smsnic",$link);

	//Obtener el mensaje
	$result1= mysql_query("SELECT * FROM mensajes where id = ".$_GET['msg'], $link) or die(mysql_error());
	if (mysql_num_rows($result1)){ 
	while ($row1 = @mysql_fetch_array($result1)){
	$delmsg = $row1['mensaje'];
	}
	}

	//Fin Obtener el mensaje
	$av=0;
	$result1= mysql_query("SELECT telefono FROM `envios` inner join telefonos on id_telefono=id where envios.id_conv=".$_GET['conv']." and envios.reg=".$_GET['prg'], $link) or die(mysql_error());
	if (mysql_num_rows($result1)){ 
	while ($row1 = @mysql_fetch_array($result1)){
	$celular= $row1['telefono'];
	


	//Remplazo de variables
	$resultVar= mysql_query("SELECT * FROM cliente where  telefono = SUBSTRING('$celular', 4, LENGTH('$celular')-3)", $link) or die(mysql_error());
	
	if (mysql_num_rows($resultVar)){ 
	while ($fila = @mysql_fetch_array($resultVar)){
		$nombreC = $fila['nombres'];
		$telefonoC = $fila['telefono'];
	}
	
	$frase_original = $delmsg;
	$sano = array("@nombre", "@cell");
	$sabroso = array($nombreC, $telefonoC);
	$nueva_frase = str_replace($sano, $sabroso, $frase_original);
	
	$sentmsg = $nueva_frase;
	
	}
	//Fin reemplazo de variables

	echo 'testFrame = document.createElement("IFRAME");
    						testFrame.id = "testFrame'.$av.'";
							frame="testFrame'.$av.'";
    						testFrame.src = "http://64.49.216.29/services/nicaragua/movistar/9494/SMSenterprise/pushScheduler.jsp?number='.$celular.'&message='.$sentmsg.'&date='.$_GET['fecha1'].'&end_date='.$_GET['fecha1'].'&time='.$_GET['hora1'].'&reg=c-'.$_GET['conv'].'-'.$_GET['prg'].'&type=delete";							
						    document.body.appendChild(testFrame);
							document.getElementById(frame).className="frame";';
	$av++;
	}
	}
	
	}
	

?>
initialize();


function regresar(){
location.href="detalle_conversacion.php?conv=<?php echo $_GET['conv']; ?>";
}
</script>
<?php
$link = mysql_connect("localhost", "admin", "Xurpas123");
mysql_select_db("smsnic",$link);


mysql_query("delete from envios 
where `envios`.`fecha`='".$_GET['fecha1']."' 
and `envios`.`hora`='".$_GET['hora1']."' 
and `envios`.`id_conv`=".$_GET['conv']."
and `envios`.`id_mensaje`=".$_GET['msg']);


mysql_query("delete from prgconv where `id_conv`=".$_GET['conv']." and id=".$_GET['prg']);


?>